package com.xiaoxing.zhinenghuacangku_zhijian.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xiaoxing.zhinenghuacangku_zhijian.R;
import com.xiaoxing.zhinenghuacangku_zhijian.mvp.ui.entity.QuYangCaoZuo;

import java.util.List;

//import me.jessyan.armscomponent.commonres.utils.GlideUtil;


public class QuYangCaoZuo1Adapter extends BaseQuickAdapter<QuYangCaoZuo, BaseViewHolder> {

    private Context mContext;
    private IChouJianChuKuLieBiaoAdapter mIChouJianChuKuLieBiaoAdapter;

    public QuYangCaoZuo1Adapter(Context context, @Nullable List<QuYangCaoZuo> data, IChouJianChuKuLieBiaoAdapter iChouJianChuKuLieBiaoAdapter) {
        super(R.layout.item_qu_yang_cao_zuo_1, data);
        this.mContext = context;
        this.mIChouJianChuKuLieBiaoAdapter = iChouJianChuKuLieBiaoAdapter;
    }

    @Override
    protected void convert(BaseViewHolder helper, QuYangCaoZuo item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        helper.setText(R.id.tv_cang_wei, "仓位: " + item.getSpname());
        helper.setText(R.id.tv_cang_wei_id, "仓位id: " + item.getSpid());
        helper.setText(R.id.tv_chou_jian_shu_liang, "抽检数量: " + item.getSpotnum());
        helper.setText(R.id.tv_ku_cun_shu_liang, "库存数量: " + item.getNums());
        helper.setText(R.id.tv_he_dui_xu_hao, "核对序号: " + item.getMid());
        helper.setText(R.id.tv_zhi_jian_ji_hua_id, "质检计划id: " + item.getMonthid());
        if (item.getIsauto().equals("1")) {
            helper.setText(R.id.tv_shi_fou_zi_dong_ku, "货架类型: 自动货架");
        } else {
            helper.setText(R.id.tv_shi_fou_zi_dong_ku, "货架类型: 人工仓位");
        }
        helper.setText(R.id.tv_qu_yang_wu_liao_ming_cheng, "取样物料名称: " + item.getMaterial());
        helper.setText(R.id.tv_qu_yang_qu, "取样区: " + item.getBuffer_name());
        helper.setText(R.id.tv_qu_yang_qu_id, "取样区id: " + item.getBufferid());
        helper.setText(R.id.tv_cang_ku_ming_cheng, "仓库名称: " + item.getStorename());
        helper.setText(R.id.tv_chou_jian_dan_wei, "抽检单位: " + item.getSpotunit());
        helper.setText(R.id.tv_miao_shu, item.getSpotnum() + item.getSpotunit() + item.getMaterial() + "从" + item.getSpname() + "放至" + item.getBuffer_name());

        helper.setOnClickListener(R.id.btn_sheng_cheng_qu_yang_ma, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIChouJianChuKuLieBiaoAdapter.shengChengQuYangMa(item);
            }
        });
        helper.setOnClickListener(R.id.btn_ren_gong_yun_zhi_feng_qian_qu, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIChouJianChuKuLieBiaoAdapter.renGongYunZhiFengQianQu("0",item);
            }
        });
        helper.setOnClickListener(R.id.btn_agv_yun_zhi_feng_qian_qu, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIChouJianChuKuLieBiaoAdapter.agvYunZhiFengQianQu("1",item);
            }
        });


    }

    public interface IChouJianChuKuLieBiaoAdapter {

        void shengChengQuYangMa(QuYangCaoZuo quYangCaoZuo);

        void renGongYunZhiFengQianQu(String type,QuYangCaoZuo quYangCaoZuo);

        void agvYunZhiFengQianQu(String type,QuYangCaoZuo quYangCaoZuo);

    }

}
